"""
@-*- coding: utf-8 -*-
@ python：python 3.8
@ 创建人员：ylx
@ 创建时间：2025/4/16 下午3:31
@ 内容：
"""
# import re
# 处理长字符串转为标准格式的方法，不要字符串里边和开头结尾这种连续的空格
#
# aa = r"                                                          [   COLLECTED   ] stage: collected                                              [FILES_CHECKING ] stage: files_checking                                         [FILES_CHECKING ] =================@qa_test/py_armory_1@1.0.0================   [FILES_CHECKING ] ===========================================================   [FILES_CHECKING ] Please review and confirm the behavior of all package files: Green + indicates new files, white ~ shows files that overwrite old ones, yellow - indicates files removed compared to the installed version,  and red ~ marks files that overwrite existing files of unknown origin. [Y/n]"
# bb = r"                      [ FILES_CHECKED ] stage: files_checked                                          [    PACKING    ] stage: packing"
# cc = r"√ Repackaging integrated package...                                            [    PACKED     ] stage: packed                                                 [   UPLOADING   ] stage: uploading                                              - Uploading integrated package and pre install scripts to remote server...mkd  /tmp/.amr/@qa_test_py_armory_1_1.0.0_1744791249326                               put  C:\Users\lenovo\AppData\Local\Temp\.armory\@qa_test_py_armory_1_1.0.0_1744791249326\@qa_test_py_armory_1_SylixOS_x86-64_1.0.0.tar.gz /tmp/.amr/@qa_test_py_armory_1_1.0.0_1744791249326/@qa_test_py_armory_1_SylixOS_x86-64_1.0.0.tar.gz   √ Uploading integrated package and pre install scripts to remote server...     [   UPLOADED    ] stage: uploaded                                               [PRE_INSTALLING ] stage: pre_installing                                         [ PRE_INSTALLED ] stage: pre_installed                                          [   UNPACKING   ] stage: unpacking                                              [   UNPACKING   ] Unpacking the package...                                      [   UNPACKING   ] > tar zxvfoP /tmp/.amr/@qa_test_py_armory_1_1.0.0_1744791249326/@qa_test_py_armory_1_SylixOS_x86-64_1.0.0.tar.gz -C /                         [   UNPACKING   ] x assets                                                      [   UNPACKING   ] x assets\\image                                               [   UNPACKING   ] x var/lib/amr/@qa_test/py_armory_1@1.0.0.installing/amr.json  [   UNPACKING   ] x var/lib/amr/@qa_test/py_armory_1@1.0.0.installing/uninst.sh [   UNPACKED    ] stage: unpacked                                               [POST_INSTALLING] stage: post_installing                                        [POST_INSTALLED ] stage: post_installed                                         [   RENAMING    ] stage: renaming                                               [   RENAMING    ] Renaming /var/lib/amr/@qa_test/py_armory_1@1.0.0.installing to /var/lib/amr/@qa_test/py_armory_1@1.0.0                                        √ > mv /var/lib/amr/@qa_test/py_armory_1@1.0.0.installing /var/lib/amr/@qa_test/py_armory_1@1.0.0                                                              [   RENAMING    ] Renamed                                                       [    RENAMED    ] stage: renamed                                                [REMOVING_OLDER ] stage: removing_older                                         [    REMOVED    ] stage: removed                                                [ FLUSH_TO_DISK ] stage: flush_to_disk                                          √ > sync                                                                       [    FLUSHED    ] stage: flushed                                                [   CLEANING    ] stage: cleaning                                               [   CLEANING    ] Cleaning remote tmp directory: /tmp/.amr/@qa_test_py_armory_1_1.0.0_1744791249326                                                             rm   \tmp\.amr\@qa_test_py_armory_1_1.0.0_1744791249326\@qa_test_py_armory_1_SylixOS_x86-64_1.0.0.tar.gz                                                        rmd  \tmp\.amr\@qa_test_py_armory_1_1.0.0_1744791249326\@qa_test_py_armory_1_SylixOS_x86-64_1.0.0.tar.gz                                                        rmr   /tmp/.amr/@qa_test_py_armory_1_1.0.0_1744791249326/                       rmrd  /tmp/.amr/@qa_test_py_armory_1_1.0.0_1744791249326/                       [   CLEANING    ] Cleaning remote backup directory: /tmp/.amr/backups           [   CLEANING    ] Cleaning local tmp directory: C:\Users\lenovo\AppData\Local\Temp\.armory\@qa_test_py_armory_1_1.0.0_1744791249326                             [    CLEANED    ] stage: cleaned                                                [   UNLOCKING   ] stage: unlocking                                              [   UNLOCKING   ] Releasing lock: /tmp/.amr/locks/apm.lock                      rmr   /tmp/.amr/locks/apm.lock/                                                 rmrd  /tmp/.amr/locks/apm.lock/                                                 [   UNLOCKING   ] Lock released.                                                [   UNLOCKED    ] stage: unlocked                                               [     DONE      ] stage: done                                                   Package @qa_test/py_armory_1@1.0.0 was successfully installed on remote server(10.12.250.46).                                                                   Installation completed."
# # 合并字符串
# merged_string = aa + bb + cc
#
# # 去除连续空格（保留单个空格）
# cleaned_string = re.sub(r'\s+', ' ', merged_string).strip()
#
# # 输出结果
# # print(cleaned_string)
#
# # 使用正则表达式按方括号 [] 分割字符串
# lines = re.split(r'(?=\[)', cleaned_string)
#
# # 去除空字符串并逐行输出
# for line in lines:
#     if line.strip():  # 确保不是空行
#         print(line.strip())







# 将vsoa  接口返回的非json 格式的字符串转换为 json格式
import json

# 原始数据
data = {
    "param": "{\"base_serv\":{\"vsoaSerId\":\"base_serv\",\"vsoaSerLoadBalanceType\":\"roundRobin\",\"vsoaSerMetaAll\":{\"instance_2-xPkIb-BAoLQVXi\":{\"id\":\"instance_2-xPkIb-BAoLQVXi\",\"nodeIp\":\"10.12.250.55\",\"hostname\":\"base_serv\",\"ctname\":\"instance_2-xPkIb-BAoLQVXi\",\"port\":44003,\"vsoaIsHealthy\":true,\"vsoaHealthyHeartbeat\":0,\"vsoaLoadBalance\":\"roundRobin\",\"vsoaMasterSlave\":null},\"instance_u6CEai-bEcNWvvaw\":{\"id\":\"instance_u6CEai-bEcNWvvaw\",\"nodeIp\":\"10.12.250.55\",\"hostname\":\"base_serv\",\"ctname\":\"instance_u6CEai-bEcNWvvaw\",\"port\":44007,\"vsoaIsHealthy\":true,\"vsoaHealthyHeartbeat\":0,\"vsoaLoadBalance\":\"roundRobin\",\"vsoaMasterSlave\":null}},\"vsoaSerMetaHealth\":{\"instance_2-xPkIb-BAoLQVXi\":{\"id\":\"instance_2-xPkIb-BAoLQVXi\",\"nodeIp\":\"10.12.250.55\",\"hostname\":\"base_serv\",\"ctname\":\"instance_2-xPkIb-BAoLQVXi\",\"port\":44003,\"vsoaIsHealthy\":true,\"vsoaHealthyHeartbeat\":0,\"vsoaLoadBalance\":\"roundRobin\",\"vsoaMasterSlave\":null},\"instance_u6CEai-bEcNWvvaw\":{\"id\":\"instance_u6CEai-bEcNWvvaw\",\"nodeIp\":\"10.12.250.55\",\"hostname\":\"base_serv\",\"ctname\":\"instance_u6CEai-bEcNWvvaw\",\"port\":44007,\"vsoaIsHealthy\":true,\"vsoaHealthyHeartbeat\":0,\"vsoaLoadBalance\":\"roundRobin\",\"vsoaMasterSlave\":null}},\"vsoaSerMetaUnHealth\":{},\"vsoaSerLoadBalanceInfo\":{\"cursor\":0,\"master\":null,\"slave\":null},\"vsoaSerName\":\"base_serv\"}}"
}

aa = """

"""

# 将 param 中的字符串解析为 JSON 对象
try:
    # 第一步：解析外层 JSON
    outer_json = json.loads(data["param"])
    print(outer_json)

    # 第二步：格式化输出
    formatted_json = json.dumps(outer_json, indent=4)
    print("Formatted JSON:")
    print(formatted_json)
    print("-------------")
    print(aa)

except json.JSONDecodeError as e:
    print("Error decoding JSON:", e)















# aa = {
#     "name": "ylx",
#     "age": 18,
#     "country": "china",
#     "hobby": {
#         "out": "",
#         "in": ""
#     }
# }
#
# bb = {
#     "name": "ylx-1",
#     "age": 18,
#     "country": "china",
#     "hobby": {
#         "out": "sing-1",
#         "in": "reading"
#     }
# }
# print(aa.items())
# for a, b in aa.items():
#     print(a, b)



